home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Development Tools & Languages / Long doubles w⁄MathLib / long_double.doc < prev    next >
Encoding:
Text File  |  1996-11-15  |  1.7 KB  |  36 lines  |  [TEXT/CWIE]

  1. This is for PowerPC only, and the assembly code at the end is PowerPC
  2. assembly.  The MathLib library is a PowerPC only library.
  3.  
  4. This code has been tested with Metrowerks Codewarrior 10 and produces
  5. the same result as standard code compiled with Mr. C (with the 128 bit
  6. long double option turned on).
  7.  
  8. This code is needed to call the MathLib functions because the current
  9. Metrowerks compilers do not create a 128 bit long double, they create
  10. a 64 bit long double.  All of the MathLib functions that require a long
  11. double expect a 128 bit long double and therefore do not produce the
  12. correct results when given a 64 bit long double.
  13.  
  14. The callMathLib1ArgFcn routine takes three pointers, two pointers to
  15. long_doubles and one ProcPtr.  The first pointer to a long_double is
  16. the argument, the second pointer to a long_double is the result, and
  17. the ProcPtr is the MathLib function to be called.
  18.  
  19. The callMathLib2ArgFcn routine takes four pointers, three pointers to
  20. long_doubles and one ProcPtr.  The first two pointers to long_double's
  21. are the first two arguments to the function to be called, the third pointer
  22. to a long_double is the result returned by the function to be called, and
  23. the ProcPtr is the MathLib function to be called (in this example the powl
  24. function).
  25.  
  26. The callMathLibXArgFcn functions set up the floating point registers,
  27. call the MathLib function, and then return the results in the result
  28. structure.
  29.  
  30. The callMathLibFcn can easily be modified to deal with other functions
  31. which don't take only long doubles or return something other than a
  32. long double, but that is left up to the reader.
  33.  
  34. There are only 5 out of 46 functions in fp.h that these two routines
  35. don't cover.
  36.